package com.uplooking.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.uplooking.service.ChartService;

@Controller
public class ChartController {

	@Autowired
	private ChartService chartService;

	@RequestMapping(value = "/chart/index1", method = RequestMethod.GET)
	public String methodChart1() {
		return "chart/index1";
	}

	@RequestMapping(value = "/chart/index2", method = RequestMethod.GET)
	public String methodChart2() {
		return "chart/index2";
	}

	@RequestMapping(value = "/chart/index3", method = RequestMethod.GET)
	public String methodChart3() {
		return "chart/index3";
	}

	@RequestMapping(value = "/chart/index4", method = RequestMethod.GET)
	public String methodChart4() {
		return "chart/index4";
	}

	@RequestMapping(value = "/chart/index5", method = RequestMethod.GET)
	public String methodChart5() {
		return "chart/index5";
	}

	@ResponseBody
	@RequiresPermissions("chart!bus")
	@RequestMapping(value = "/chart/bus", method = RequestMethod.GET, produces = { "application/json;charset=utf-8" })
	public String methodChart6() {
		return JSONObject.toJSONString(chartService.getBusCount());
	}

	@ResponseBody
	@RequiresPermissions("chart!cust")
	@RequestMapping(value = "/chart/cust", method = RequestMethod.GET, produces = { "application/json;charset=utf-8" })
	public String methodChart7() {
		return JSONObject.toJSONString(chartService.getCustCount());
	}

	@ResponseBody
	@RequiresPermissions("chart!user")
	@RequestMapping(value = "/chart/user", method = RequestMethod.GET, produces = { "application/json;charset=utf-8" })
	public String methodChart8() {
		return JSONObject.toJSONString(chartService.getCustMoney());
	}

	@ResponseBody
	@RequiresPermissions("chart!month")
	@RequestMapping(value = "/chart/month", method = RequestMethod.GET, produces = { "application/json;charset=utf-8" })
	public String methodChart9() {
		return JSONObject.toJSONString(chartService.getCustMoneyByMonth());
	}

	@ResponseBody
	@RequiresPermissions("chart!company")
	@RequestMapping(value = "/chart/company", method = RequestMethod.GET, produces = {
			"application/json;charset=utf-8" })
	public String methodChart10() {
		return JSONObject.toJSONString(chartService.getCustMoneyByYear());
	}

}
